const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    QQnickname: "",
    WXnickname: "武振鹏",
    isQQ: 0,
    isWx: 0,
    codename:'获取验证码',
    disabled:true, 
    Tel:'',   
    inputYzm:'',
    isjb:false,
  },
  inputTel:function (e) {
    this.setData({
      Tel:e.detail.value
    }) 
  }, 
  isjb:function () {
    this.setData({
      isjb:true
    })
  },
  isqx:function () {
    this.setData({
      isjb:false
    })
  },  
  inputYzm:function (e) {
    this.setData({
      inputYzm:e.detail.value
    }) 
  },  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    var FjLoginLog = wx.getStorageSync('FjLoginLog');
    var api_input = {
      uid:FjLoginLog.UID
    }
    app.getDaoPost('api/FeijiuApp/PostLoginLogIsBind_QQWx',api_input,function (r) {
      console.log(r)
      if (r.code = 200) {
        that.setData({
          QQnickname: r.data.QQnickname,
          WXnickname: r.data.WXnickname,
          isQQ: r.data.isQQ,
          isWx: r.data.isWx,          
        })
      }
    })
    // 

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  jbwx:function () {
    this.setData({
      isjb:true
    })
  },
  getCode:function(){    
    var that = this;
    var tel = this.data.Tel;
    var myreg = /^(14[0-9]|16[0-9]|19[0-9]|13[0-9]|15[0-9]|17[0-9]|18[0-9])\d{8}$$/;
    if (!myreg.test(tel)) {
      app.tishi('请输入正确的手机号');
      return false;      
    }else{
      var api_input = {
        tel:this.data.Tel
      }
      app.getDaoPost('api/FeijiuApp/PostSendYzm_SMS_New',api_input,function (r) {
        if (r.code == 200) {
          app.tishi(r.data.Mess);
          var num = 61;
          var timer = setInterval(function () {
            num--;
            if (num <= 0) {
              clearInterval(timer);
              that.setData({
                codename: '重新发送',
                disabled: true,                
              }) 
            } else {
              that.setData({
                codename: num + "s后重新获取",
                disabled: false,       
              })
            }
          }, 1000)
        }else{
          app.tishi(r.message)
        }
      })
    }
  },  
  logingetyzmN:function () {
    
  },  
  logingetyzm:function () {
    this.getCode();
  }, 
  jbfun:function () {
    var that =this;
    var FjLoginLog = wx.getStorageSync('FjLoginLog');
    var api_input = {
      uid:FjLoginLog.UID,
      Tel:this.data.Tel,
      YZM:this.data.inputYzm
    } 
    app.getDaoPost('api/FeijiuApp/PostLoginLogUNBind_Wx',api_input,function (r) {
      console.log(r)
      if (r.code == 200) {
        app.tishi('解绑成功');
        setTimeout(function () {
          wx.navigateBack()
        },2000)
      }else{
        app.tishi('解绑失败:原因'+r.message);
      }
    })
  },
  quxiao:function () {
    this.setData({
      isjb:false
    })
  }

})